import {reqGetUserAdress,reqGetShopList} from '@/api'
const state = {
  // 初始值
  addressInfo:[],
  shopList:{}
};
const mutations = {
  GETUSERADDRESS(state,addressInfo){
    state.addressInfo = addressInfo
  },
  GETSHOPLIST(state,shopList){
    state.shopList = shopList
  }
};
const actions = {
  async getUserAddress({commit}){
    let res = await reqGetUserAdress()
    if(res.code == 200){
      commit('GETUSERADDRESS',res.data)
      return 'ok'
    }else {
      return Promise.reject(new Error('失败了！'))
    }
  },
  // 获取商品清单
  async getShopList({commit}){
    let res = await reqGetShopList()
    if(res.code == 200){
      commit('GETSHOPLIST',res.data)
      return 'ok'
    }else {
      return Promise.reject(new Error('失败了！'))
    }
  },
  
};
const getters = {

};
export default {
  state,
  mutations,
  actions,
  getters
}